﻿<UserControl x:Class="personalplaner.gui.stamm.views.DienstZeitZeitView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:conv="clr-namespace:personalplaner.common.converters;assembly=personalplaner.common"
        xmlns:c="clr-namespace:personalplaner.common.controls;assembly=personalplaner.common"
        xmlns:bs="clr-namespace:personalplaner.business.stamm;assembly=personalplaner.business"
        xmlns:local="clr-namespace:personalplaner.gui.stamm.views"
        xmlns:p="clr-namespace:personalplaner.gui.Properties">

    <Grid>
        
        <Grid.Resources>
            <conv:BoolInvertConverter x:Key="boolInvert"/>

            <DataTemplate DataType="{x:Type bs:DienstZeitEinheit}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="100"/>
                        <ColumnDefinition Width="100"/>
                        <ColumnDefinition Width="100"/>
                        <ColumnDefinition Width="100"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="{Binding Von}" Margin="0,0,10,0" FontWeight="Normal"/>
                    <TextBlock Text="{Binding Bis}" Grid.Column="1" Margin="0,0,10,0" FontWeight="Normal"/>
                    <TextBlock Text="{Binding ZeitTyp}" Grid.Column="2" Margin="0,0,10,0" FontWeight="Normal"/>
                    <TextBlock Text="{Binding Zeit}" Grid.Column="3" FontWeight="Normal"/>

                    <!--Style="{StaticResource TransparentButtonStyle}"-->
                    <Button  HorizontalAlignment="Left" Grid.Column="4"  Margin="17,0,0,0" Cursor="Hand" Width="16" Height="16"
                                Command="{Binding DataContext.DeleteTimeCommand, RelativeSource={RelativeSource AncestorType={x:Type local:DienstZeitZeitView}}}" CommandParameter="{Binding}"
                             ToolTip="{x:Static p:Resources.DienstZeitEntfernen}">
                        <Path Data="M 0,4 L 8,4" StrokeThickness="3" Stroke="Red" VerticalAlignment="Center" Height="8" HorizontalAlignment="Center"/>
                    </Button>

                </Grid>
            </DataTemplate>
            
        </Grid.Resources>
        
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition Width="300"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
        </Grid.RowDefinitions>

        <TextBlock Text="{x:Static p:Resources.Zeit}" FontSize="16" FontWeight="Heavy" Margin="40,0,0,20"/>

        <TextBlock Text="{x:Static p:Resources.Von}" Grid.Row="1" HorizontalAlignment="Left" Margin="20,0,10,0" />
        <c:MaskedTextBox Grid.Column="1" Grid.Row="1" Text="{Binding Von, UpdateSourceTrigger=LostFocus}" PreviewTextInput="MaskedTextBox_PreviewTextInput" TextChanged="MaskedTextBox_TextChanged" Mask="00:00" />

        <TextBlock Text="{x:Static p:Resources.Bis}" Grid.Row="2" HorizontalAlignment="Left" Margin="20,0,10,0" />
        <c:MaskedTextBox Grid.Column="1" Grid.Row="2" Text="{Binding Bis, UpdateSourceTrigger=LostFocus}" PreviewTextInput="MaskedTextBox_PreviewTextInput" TextChanged="MaskedTextBox_TextChanged" Mask="00:00" />

        <TextBlock Text="{x:Static p:Resources.Zeit}" Grid.Row="3" HorizontalAlignment="Left" Margin="20,0,10,0"/>
        <c:NumericTextBox Grid.Column="1" Grid.Row="3" Text="{Binding Zeit, UpdateSourceTrigger=LostFocus}"/>

        <TextBlock Text="{x:Static p:Resources.ArtDerZeit}" Grid.Row="4" HorizontalAlignment="Left" Margin="20,0,10,0"/>
        <ComboBox Grid.Column="1" Grid.Row="4" ItemsSource="{Binding ZeitTypen}" SelectedItem="{Binding SelectedZeitTyp}"/>

        <!--<Button Style="{StaticResource TransparentButtonStyle}" Command="{Binding AddTimeCommand}" Cursor="Hand" Grid.Row="3" Grid.Column="2" Width="20" HorizontalAlignment="Left" Margin="40,0,0,0">
            <Image Source="/personalplaner.gui;component/resources/images/Add.png" Height="16"/>
        </Button>-->
        <Button Command="{Binding AddTimeCommand}" Cursor="Hand" Grid.Row="5" Grid.Column="1" HorizontalAlignment="Right" Margin="40,5,0,0">
            <TextBlock Text="{x:Static p:Resources.AddTime}"/>
        </Button>

        <GroupBox Grid.Row="6" Grid.ColumnSpan="3" Margin="20,0,0,0" Header="Zeiten" BorderBrush="Transparent" >
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition/>
                </Grid.RowDefinitions>

                <TextBlock Text="{x:Static p:Resources.Von}" FontWeight="Heavy"/>
                <TextBlock Text="{x:Static p:Resources.Bis}" Grid.Column="1" FontWeight="Heavy"/>
                <TextBlock Text="{x:Static p:Resources.Typ}" Grid.Column="2" FontWeight="Heavy"/>
                <TextBlock Text="{x:Static p:Resources.Total}" Grid.Column="3" FontWeight="Heavy"/>

                <Border Grid.Row="1" Grid.ColumnSpan="4" BorderBrush="Black" BorderThickness="0,1,0,0" Background="Transparent" Margin="0,5,0,0">
                    <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto" >
                        <ItemsControl ItemsSource="{Binding Zeiten}" />
                    </ScrollViewer>
                </Border>
                
            </Grid>

        </GroupBox>
    </Grid>
    
</UserControl>
